﻿Imports DotNetNuke
Imports DotNetNuke.Services.Exceptions.Exceptions
Imports DotNetNuke.Common.Utilities

Imports DotNetNuke.Entities.Profile

Imports DotNetNuke.Services.Localization
Imports DotNetNuke.Security.Roles
Imports DotNetNuke.Common.Lists

Namespace effority.UserDirectory

    Partial Class Settings
        Inherits Base

        Private _RolesConfiguration As Generic.Dictionary(Of Int32, Enums.RoleStatus)

        Public ReadOnly Property RolesConfiguration() As Generic.Dictionary(Of Int32, Enums.RoleStatus)
            Get

                If _RolesConfiguration Is Nothing Then

                    _RolesConfiguration = New Generic.Dictionary(Of Int32, Enums.RoleStatus)

                    If Not String.IsNullOrEmpty(CStr(Settings(Consts.ADD_ROLES))) Then

                        Dim addRoles As String() = CStr(Settings(Consts.ADD_ROLES)).Split(";"c)

                        For Each str As String In addRoles
                            If Not String.IsNullOrEmpty(str) Then
                                _RolesConfiguration.Add(CInt(str), Enums.RoleStatus.Add)
                            End If
                        Next

                    End If

                    If Not String.IsNullOrEmpty(CStr(Settings(Consts.REMOVE_ROLES))) Then

                        Dim removeRoles As String() = CStr(Settings(Consts.REMOVE_ROLES)).Split(";"c)

                        For Each str As String In removeRoles
                            If Not String.IsNullOrEmpty(str) Then
                                _RolesConfiguration.Add(CInt(str), Enums.RoleStatus.Remove)
                            End If
                        Next

                    End If

                    If Not String.IsNullOrEmpty(CStr(Settings(Consts.IGNORE_ROLES))) Then

                        Dim ignoreRoles As String() = CStr(Settings(Consts.IGNORE_ROLES)).Split(";"c)

                        For Each str As String In ignoreRoles
                            If Not String.IsNullOrEmpty(str) Then
                                _RolesConfiguration.Add(CInt(str), Enums.RoleStatus.Ignore)
                            End If
                        Next

                    End If

                    ' Standwerte für nicht konfigurierte Rolen erzeugen 

                    Dim rolesCont As New DotNetNuke.Security.Roles.RoleController

                    Dim roles As ArrayList = rolesCont.GetPortalRoles(PortalId)

                    For Each role As DotNetNuke.Security.Roles.RoleInfo In roles

                        If Not _RolesConfiguration.TryGetValue(role.RoleID, Nothing) Then

                            If role.RoleID = PortalSettings.AdministratorRoleId Then

                                _RolesConfiguration.Add(role.RoleID, Enums.RoleStatus.Remove)

                            Else

                                _RolesConfiguration.Add(role.RoleID, Enums.RoleStatus.Add)

                            End If

                        End If

                    Next

                End If

                Return _RolesConfiguration

            End Get
        End Property

        Public ReadOnly Property USERTABLE_MODULE_CACHE() As String
            Get
                Return Consts.USERTABLE_CACHE & Me.ModuleId
            End Get
        End Property

#Region " Overrided Methods "

        Public Overrides Sub LoadSettings()

            Try

                'Paging Settings
                'If CType(TabModuleSettings("paging"), String) <> "" Then
                '    ddlPaging.SelectedValue = TabModuleSettings("paging")
                'End If

                If Not Settings("paging") Is Nothing Then
                    ddlPaging.SelectedValue = Settings("paging")
                End If

                ' Profile SHOW Settings
                If Not Settings(effority.UserDirectory.Consts.EMAIL_FIELD_WITH_MAILTO) Is Nothing Then
                    cbMailTo.Checked = CBool(Settings(effority.UserDirectory.Consts.EMAIL_FIELD_WITH_MAILTO))
                End If

                gvProfileShow.DataSource = Me.ProfilePropertyCollection
                gvProfileShow.DataBind()

                If Not Settings(effority.UserDirectory.Consts.PROFILES_SHOW_ALL) Is Nothing Then
                    cbProfilesShowAll.Checked = CBool(Settings(effority.UserDirectory.Consts.PROFILES_SHOW_ALL))
                Else
                    cbProfilesShowAll.Checked = True
                End If

                If Not Settings(effority.UserDirectory.Consts.PROFILES_SEARCH_ALL) Is Nothing Then
                    cbProfilesSearchAll.Checked = CBool(Settings(effority.UserDirectory.Consts.PROFILES_SEARCH_ALL))
                Else
                    cbProfilesSearchAll.Checked = True
                End If

                ' Profile SEARCH/FILTER Settings
                rptProfilesSearch.DataSource = Me.ProfilePropertyCollection
                rptProfilesSearch.DataBind()

                'If Not cbProfilesSearchAll.Checked Then
                '    rptProfilesSearch.Visible = True
                'Else
                '    rptProfilesSearch.Visible = False
                'End If

                If Not Settings(effority.UserDirectory.Consts.SHOW_PROFILES_TO_SEARCH_SETTINGS) Is Nothing Then
                    cbShowProfilesSearchSettings.Checked = CBool(Settings(effority.UserDirectory.Consts.SHOW_PROFILES_TO_SEARCH_SETTINGS))
                Else
                    cbShowProfilesSearchSettings.Checked = True
                End If

                'Roles Settings

                cbIgnoreEffectiveExpire.Checked = Me.IgnoreEffectiveExpireDate

                Dim rolesCont As New DotNetNuke.Security.Roles.RoleController

                Dim roles As ArrayList = rolesCont.GetPortalRoles(PortalId)

                dlRoles.DataSource = roles
                dlRoles.DataBind()

                ' Search Settings

                If Not Settings(effority.UserDirectory.Consts.DISABLE_SEARCH) Is Nothing Then
                    cbDisableSearch.Checked = CBool(Settings(effority.UserDirectory.Consts.DISABLE_SEARCH))
                Else
                    cbDisableSearch.Checked = False
                End If

                ' Sort 

                ddlSortColumn.DataSource = Me.ProfilePropertyCollection
                ddlSortColumn.DataValueField = "PropertyDefinitionId"
                ddlSortColumn.DataTextField = "PropertyName"
                ddlSortColumn.DataBind()

                If Not Settings(Consts.SORT_COLUMN) Is Nothing Then
                    ddlSortColumn.SelectedValue = CStr(Settings(Consts.SORT_COLUMN))
                End If

                If Not Settings(Consts.SORT_DIRECTION) Is Nothing Then
                    ddlSortDirection.SelectedValue = CStr(Settings(Consts.SORT_DIRECTION))
                End If

                ' Start Mode RadioButtons
                If Settings(effority.UserDirectory.Consts.SEARCH_START_MODE) Is Nothing Then
                    rbShowNo.Checked = True
                Else
                    If CType(Settings(effority.UserDirectory.Consts.SEARCH_START_MODE), Enums.SearchStartMode) = Enums.SearchStartMode.ShowNoRecords Then
                        rbShowNo.Checked = True
                    Else
                        rbShowAll.Checked = True
                    End If
                End If

                If Not Settings(effority.UserDirectory.Consts.DEFAULT_SEARCH_EXPRESSION) Is Nothing Then
                    txtdefaultSearchExpression.Text = CStr(Settings(effority.UserDirectory.Consts.DEFAULT_SEARCH_EXPRESSION))
                End If

                If Not Settings(effority.UserDirectory.Consts.MIN_CHAR) Is Nothing Then
                    ddlMinChar.SelectedValue = CStr(Settings(effority.UserDirectory.Consts.MIN_CHAR))
                End If

                ' Display Mode Settings

                If Me.DisplayMode = Enums.DisplayMode.Grid Then
                    rbDisplaySettings_01.Checked = True
                Else
                    rbDisplaySettings_02.Checked = True
                End If

                txtDisplayTemplate.Text = Me.DisplayTemplate
                txtDisplayHeadTemplate.Text = Me.DisplayHeadTemplate


                ' Profile Link Settings

                ddlColumnForProfileLink.DataSource = Me.ProfilePropertyCollection
                ddlColumnForProfileLink.DataValueField = "PropertyDefinitionId"
                ddlColumnForProfileLink.DataTextField = "PropertyName"
                ddlColumnForProfileLink.DataBind()

                If Not Settings(effority.UserDirectory.Consts.ENABLE_PROFILE_LINK) Is Nothing Then
                    cbEnableProfileLink.Checked = CBool(Settings(effority.UserDirectory.Consts.ENABLE_PROFILE_LINK))
                End If

                If Not Settings(effority.UserDirectory.Consts.COLUMN_FOR_PROFILE_LINK) Is Nothing Then
                    ddlColumnForProfileLink.SelectedValue = CStr(Settings(effority.UserDirectory.Consts.COLUMN_FOR_PROFILE_LINK))
                End If

                ' Detail Page Settings

                ddlColumnForDetailPage.DataSource = Me.ProfilePropertyCollection
                ddlColumnForDetailPage.DataValueField = "PropertyDefinitionId"
                ddlColumnForDetailPage.DataTextField = "PropertyName"
                ddlColumnForDetailPage.DataBind()

                If Not Settings(effority.UserDirectory.Consts.DETAILS_VIEW_ENABLE) Is Nothing Then
                    cbDetails.Checked = CBool(Settings(effority.UserDirectory.Consts.DETAILS_VIEW_ENABLE))
                End If

                If Not Settings(effority.UserDirectory.Consts.DETAILS_VIEW_COLUMN) Is Nothing Then
                    ddlColumnForDetailPage.SelectedValue = CStr(Settings(effority.UserDirectory.Consts.DETAILS_VIEW_COLUMN))
                End If

                If Not Settings(effority.UserDirectory.Consts.DETAILS_VIEW_TEMPLATE) Is Nothing Then
                    txtDetailsTemplate.Text = CStr(Settings(effority.UserDirectory.Consts.DETAILS_VIEW_TEMPLATE))
                End If

                ' vCard Settings

                ddlColumnForvCard.DataSource = Me.ProfilePropertyCollection
                ddlColumnForvCard.DataValueField = "PropertyDefinitionId"
                ddlColumnForvCard.DataTextField = "PropertyName"
                ddlColumnForvCard.DataBind()

                If Not Settings(effority.UserDirectory.Consts.VCARD_LINK_ENABLE) Is Nothing Then
                    cbEnablevCard.Checked = CBool(Settings(effority.UserDirectory.Consts.VCARD_LINK_ENABLE))
                End If

                If Not Settings(effority.UserDirectory.Consts.VCARD_LINK_COLUMN) Is Nothing Then
                    ddlColumnForvCard.SelectedValue = CStr(Settings(effority.UserDirectory.Consts.VCARD_LINK_COLUMN))
                End If

                If Not Settings(effority.UserDirectory.Consts.VCARD_LINK_TEMPLATE) Is Nothing Then
                    txtvCardTemplate.Text = CStr(Settings(effority.UserDirectory.Consts.VCARD_LINK_TEMPLATE))
                End If

                ' Tab Link Settings

                ddlColumnForTabLink.DataSource = Me.ProfilePropertyCollection
                ddlColumnForTabLink.DataValueField = "PropertyDefinitionId"
                ddlColumnForTabLink.DataTextField = "PropertyName"
                ddlColumnForTabLink.DataBind()

                If Not Settings(effority.UserDirectory.Consts.TAB_LINK_ENABLE) Is Nothing Then
                    cbEnableTabLink.Checked = CBool(Settings(effority.UserDirectory.Consts.TAB_LINK_ENABLE))
                End If

                If Not Settings(effority.UserDirectory.Consts.TAB_LINK_COLUMN) Is Nothing Then
                    ddlColumnForTabLink.SelectedValue = CStr(Settings(effority.UserDirectory.Consts.TAB_LINK_COLUMN))
                End If

                If Not Settings(effority.UserDirectory.Consts.TAB_LINK_NEW_WINDOW) Is Nothing Then
                    cbTabLinkNewWindow.Checked = CBool(Settings(effority.UserDirectory.Consts.TAB_LINK_NEW_WINDOW))
                End If

                ' nicht mehr implementiert 17.08.08
                'If Not Settings(effority.UserDirectory.Consts.TAB_LINK_TEXT) Is Nothing Then
                '   txtTabLink.Text = CStr(Settings(effority.UserDirectory.Consts.TAB_LINK_TEXT))
                'End If

                ' Extended Role Settings
                ddlSelectExtendedRole.DataTextField = "RoleName"
                ddlSelectExtendedRole.DataValueField = "RoleID"
                ddlSelectExtendedRole.DataSource = New RoleController().GetPortalRoles(PortalId)
                ddlSelectExtendedRole.DataBind()
                ddlSelectExtendedRole.Items.Insert(0, New ListItem(Localization.GetString("ddlSelectExtendedRole.None", LocalResourceFile), "-1"))

                If Not Settings(effority.UserDirectory.Consts.EXTENDEDROLE) Is Nothing Then
                    Dim tempItem As ListItem = ddlSelectExtendedRole.Items.FindByValue(Settings(effority.UserDirectory.Consts.EXTENDEDROLE).ToString)
                    If Not tempItem Is Nothing Then
                        ddlSelectExtendedRole.SelectedIndex = ddlSelectExtendedRole.Items.IndexOf(tempItem)
                    End If
                End If

                If Not Settings(effority.UserDirectory.Consts.EXTENDEDROLE_PAGE) Is Nothing Then
                    txtExtendedRolePage.Text = Settings(effority.UserDirectory.Consts.EXTENDEDROLE_PAGE).ToString
                End If

            Catch exc As Exception

                ProcessModuleLoadException(Me, exc)

            End Try

        End Sub

        Public Overrides Sub UpdateSettings()

            Try

                If Page.IsValid Then

                    Dim objModules As New Entities.Modules.ModuleController

                    'Paging Settings
                    objModules.UpdateModuleSetting(ModuleId, "paging", CStr(ddlPaging.SelectedValue))

                    ' Profile Show Settings
                    objModules.UpdateModuleSetting(ModuleId, effority.UserDirectory.Consts.EMAIL_FIELD_WITH_MAILTO, CStr(cbMailTo.Checked))

                    Dim profilesShowStr As String = String.Empty
                    Dim maxLengthStr As String = String.Empty
                    Dim htmlDecodeStr As String = String.Empty
                    Dim extendedRoleProfileStr As String = String.Empty

                    For Each row As System.Web.UI.WebControls.GridViewRow In gvProfileShow.Rows

                        Dim lblId As Label = CType(row.FindControl("lblId"), Label)

                        Dim cbProfileShow As CheckBox = CType(row.FindControl("cbProfileShow"), CheckBox)
                        Dim txtMaxLength As TextBox = CType(row.FindControl("txtMaxLength"), TextBox)
                        Dim cbHtmlDecode As CheckBox = CType(row.FindControl("cbHtmlDecode"), CheckBox)
                        Dim cbExtendedRoleOnly As CheckBox = CType(row.FindControl("cbExtendedRoleOnly"), CheckBox)

                        If Not cbProfileShow Is Nothing Then

                            If cbProfileShow.Checked = True Then
                                profilesShowStr &= ";" & lblId.Text & ";"
                            End If

                        End If

                        If Not txtMaxLength Is Nothing Then
                            maxLengthStr &= lblId.Text & "|" & txtMaxLength.Text & ";"
                        End If

                        If Not cbHtmlDecode Is Nothing Then

                            If cbHtmlDecode.Checked = True Then
                                htmlDecodeStr &= lblId.Text & "|" & cbHtmlDecode.Checked & ";"
                            End If

                        End If

                        If Not cbExtendedRoleOnly Is Nothing Then

                            If cbExtendedRoleOnly.Checked = True Then
                                extendedRoleProfileStr &= lblId.Text & "|" & cbExtendedRoleOnly.Checked & ";"
                            End If

                        End If

                    Next

                    objModules.UpdateModuleSetting(ModuleId, effority.UserDirectory.Consts.PROFILES_SHOW_ALL, CStr(cbProfilesShowAll.Checked))

                    If Not profilesShowStr = String.Empty Then
                        objModules.UpdateModuleSetting(ModuleId, effority.UserDirectory.Consts.PROFILES_TO_SHOW, profilesShowStr)
                    Else
                        objModules.UpdateModuleSetting(ModuleId, effority.UserDirectory.Consts.PROFILES_TO_SHOW, DBNull.Value.ToString)
                    End If

                    If Not maxLengthStr = String.Empty Then
                        objModules.UpdateModuleSetting(ModuleId, effority.UserDirectory.Consts.MAX_LENGTH, maxLengthStr)
                    Else
                        objModules.UpdateModuleSetting(ModuleId, effority.UserDirectory.Consts.MAX_LENGTH, DBNull.Value.ToString)
                    End If

                    If Not htmlDecodeStr = String.Empty Then
                        objModules.UpdateModuleSetting(ModuleId, effority.UserDirectory.Consts.HTML_DECODE, htmlDecodeStr)
                    Else
                        objModules.UpdateModuleSetting(ModuleId, effority.UserDirectory.Consts.HTML_DECODE, DBNull.Value.ToString)
                    End If

                    If Not extendedRoleProfileStr = String.Empty Then
                        objModules.UpdateModuleSetting(ModuleId, effority.UserDirectory.Consts.EXTENDEDROLE_PROFILES, extendedRoleProfileStr)
                    Else
                        objModules.UpdateModuleSetting(ModuleId, effority.UserDirectory.Consts.EXTENDEDROLE_PROFILES, DBNull.Value.ToString)
                    End If

                    ' Profile Search Settings

                    Dim rptProfilesSearchStr As String = ""
                    Dim rptProfilesFilterStr As String = ""

                    For Each rptRepeaterItem As RepeaterItem In rptProfilesSearch.Items
                        Dim cbx As CheckBox
                        Dim id As Integer = CType(rptRepeaterItem.FindControl("hidProfileID"), HiddenField).Value

                        cbx = CType(rptRepeaterItem.FindControl("cbxSearch"), CheckBox)
                        If cbx.Checked Then
                            rptProfilesSearchStr &= ";" & id & ";"
                        End If

                        cbx = CType(rptRepeaterItem.FindControl("cbxFilter"), CheckBox)
                        If cbx.Checked Then
                            rptProfilesFilterStr &= ";" & id & ";"
                        End If

                    Next

                    If Not rptProfilesSearchStr = "" Then
                        objModules.UpdateModuleSetting(ModuleId, effority.UserDirectory.Consts.PROFILES_TO_SEARCH, rptProfilesSearchStr)
                    Else
                        objModules.UpdateModuleSetting(ModuleId, effority.UserDirectory.Consts.PROFILES_TO_SEARCH, DBNull.Value.ToString)
                    End If

                    If Not rptProfilesFilterStr = "" Then
                        objModules.UpdateModuleSetting(ModuleId, effority.UserDirectory.Consts.PROFILES_TO_FILTER, rptProfilesFilterStr)
                    Else
                        objModules.UpdateModuleSetting(ModuleId, effority.UserDirectory.Consts.PROFILES_TO_FILTER, DBNull.Value.ToString)
                    End If

                    objModules.UpdateModuleSetting(ModuleId, effority.UserDirectory.Consts.PROFILES_SEARCH_ALL, CStr(cbProfilesSearchAll.Checked))

                    objModules.UpdateModuleSetting(ModuleId, effority.UserDirectory.Consts.SHOW_PROFILES_TO_SEARCH_SETTINGS, CStr(cbShowProfilesSearchSettings.Checked))

                    ' Roles Settings

                    objModules.UpdateModuleSetting(ModuleId, effority.UserDirectory.Consts.IGNORE_EFFECTIVE_EXPIRE_DATES, CStr(cbIgnoreEffectiveExpire.Checked))

                    Dim addRoles As String = ";"
                    Dim removeRoles As String = ";"
                    Dim ignoreRoles As String = ";"

                    For Each item As DataListItem In dlRoles.Items

                        Dim lblRole As Label = CType(item.FindControl("lblRole"), Label)

                        Dim rblRole As RadioButtonList = CType(item.FindControl("rblRoles"), RadioButtonList)

                        Dim roleCont As New DotNetNuke.Security.Roles.RoleController

                        Dim role As DotNetNuke.Security.Roles.RoleInfo = roleCont.GetRoleByName(PortalId, lblRole.Text)

                        If Not role Is Nothing Then

                            Select Case rblRole.SelectedIndex

                                Case 0
                                    addRoles &= role.RoleID & ";"
                                Case 1
                                    removeRoles &= role.RoleID & ";"
                                Case 2
                                    ignoreRoles &= role.RoleID & ";"

                            End Select

                        End If

                    Next

                    objModules.UpdateModuleSetting(ModuleId, effority.UserDirectory.Consts.ADD_ROLES, addRoles)
                    objModules.UpdateModuleSetting(ModuleId, effority.UserDirectory.Consts.REMOVE_ROLES, removeRoles)
                    objModules.UpdateModuleSetting(ModuleId, effority.UserDirectory.Consts.IGNORE_ROLES, ignoreRoles)

                    ' Search Settings
                    objModules.UpdateModuleSetting(ModuleId, effority.UserDirectory.Consts.DISABLE_SEARCH, CStr(cbDisableSearch.Checked))
                    objModules.UpdateModuleSetting(ModuleId, effority.UserDirectory.Consts.DEFAULT_SEARCH_EXPRESSION, txtdefaultSearchExpression.Text)
                    objModules.UpdateModuleSetting(ModuleId, effority.UserDirectory.Consts.MIN_CHAR, CStr(ddlMinChar.SelectedValue))

                    If rbShowNo.Checked Then
                        objModules.UpdateModuleSetting(ModuleId, effority.UserDirectory.Consts.SEARCH_START_MODE, CStr(Enums.SearchStartMode.ShowNoRecords))
                    Else
                        objModules.UpdateModuleSetting(ModuleId, effority.UserDirectory.Consts.SEARCH_START_MODE, CStr(Enums.SearchStartMode.ShowAllRecords))
                    End If

                    ' Sort

                    objModules.UpdateModuleSetting(ModuleId, effority.UserDirectory.Consts.SORT_COLUMN, ddlSortColumn.SelectedValue)
                    objModules.UpdateModuleSetting(ModuleId, effority.UserDirectory.Consts.SORT_DIRECTION, ddlSortDirection.SelectedValue)

                    ' Display Mode Settings

                    If rbDisplaySettings_01.Checked Then
                        objModules.UpdateModuleSetting(ModuleId, effority.UserDirectory.Consts.DISPLAY_MODE, CStr(Enums.DisplayMode.Grid))
                    ElseIf rbDisplaySettings_02.Checked Then
                        objModules.UpdateModuleSetting(ModuleId, effority.UserDirectory.Consts.DISPLAY_MODE, CStr(Enums.DisplayMode.Template))
                    End If

                    objModules.UpdateModuleSetting(ModuleId, effority.UserDirectory.Consts.DISPLAY_TEMPLATE, txtDisplayTemplate.Text)
                    objModules.UpdateModuleSetting(ModuleId, effority.UserDirectory.Consts.DISPLAY_HEAD_TEMPLATE, txtDisplayHeadTemplate.Text)

                    ' Profile Link Settings
                    objModules.UpdateModuleSetting(ModuleId, effority.UserDirectory.Consts.ENABLE_PROFILE_LINK, CStr(cbEnableProfileLink.Checked))
                    objModules.UpdateModuleSetting(ModuleId, effority.UserDirectory.Consts.COLUMN_FOR_PROFILE_LINK, CStr(ddlColumnForProfileLink.SelectedValue))

                    ' Detail Page Settings

                    objModules.UpdateModuleSetting(ModuleId, effority.UserDirectory.Consts.DETAILS_VIEW_ENABLE, CStr(cbDetails.Checked))
                    objModules.UpdateModuleSetting(ModuleId, effority.UserDirectory.Consts.DETAILS_VIEW_COLUMN, ddlColumnForDetailPage.SelectedValue)
                    objModules.UpdateModuleSetting(ModuleId, effority.UserDirectory.Consts.DETAILS_VIEW_TEMPLATE, txtDetailsTemplate.Text)

                    ' vCard Settings
                    objModules.UpdateModuleSetting(ModuleId, effority.UserDirectory.Consts.VCARD_LINK_ENABLE, CStr(cbEnablevCard.Checked))
                    objModules.UpdateModuleSetting(ModuleId, effority.UserDirectory.Consts.VCARD_LINK_COLUMN, ddlColumnForvCard.SelectedValue)
                    objModules.UpdateModuleSetting(ModuleId, effority.UserDirectory.Consts.VCARD_LINK_TEMPLATE, txtvCardTemplate.Text)

                    ' Tab Link Settings
                    objModules.UpdateModuleSetting(ModuleId, effority.UserDirectory.Consts.TAB_LINK_ENABLE, CStr(cbEnableTabLink.Checked))
                    objModules.UpdateModuleSetting(ModuleId, effority.UserDirectory.Consts.TAB_LINK_COLUMN, ddlColumnForTabLink.SelectedValue)

                    ' nicht mehr implementiert 17.08.08
                    'objModules.UpdateModuleSetting(ModuleId, effority.UserDirectory.Consts.TAB_LINK_TEXT, txtTabLink.Text)

                    objModules.UpdateModuleSetting(ModuleId, effority.UserDirectory.Consts.TAB_LINK_NEW_WINDOW, cbTabLinkNewWindow.Checked)

                    ' Extended Role Settings
                    objModules.UpdateModuleSetting(ModuleId, effority.UserDirectory.Consts.EXTENDEDROLE, ddlSelectExtendedRole.SelectedValue)

                    objModules.UpdateModuleSetting(ModuleId, effority.UserDirectory.Consts.EXTENDEDROLE_PAGE, txtExtendedRolePage.Text)


                End If

            Catch exc As Exception

                ProcessModuleLoadException(Me, exc)

            End Try

        End Sub

#End Region

#Region " Event Handlers "

        Protected Sub cbProfileSearchAll_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cbProfilesSearchAll.CheckedChanged
            'rptProfilesSearch.Visible = Not cbProfilesSearchAll.Checked
        End Sub

        Protected Sub cbProfileShowAll_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cbProfilesShowAll.CheckedChanged

            'cblProfilesShow.Enabled = Not cbProfilesShowAll.Checked

            Dim objModules As New Entities.Modules.ModuleController

            objModules.UpdateModuleSetting(ModuleId, effority.UserDirectory.Consts.PROFILES_SHOW_ALL, CStr(cbProfilesShowAll.Checked))

            gvProfileShow.DataSource = Me.ProfilePropertyCollection()
            gvProfileShow.DataBind()

        End Sub

        Protected Sub cbDisableSearch_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cbDisableSearch.CheckedChanged
            'txtdefaultSearchExpression.Enabled = cbDisableSearch.Checked
        End Sub

        Protected Sub btClearCache_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btClearCache.Click

            DotNetNuke.Services.Cache.CachingProvider.Instance.Remove(Me.USERTABLE_MODULE_CACHE)

        End Sub

        Protected Sub dlRoles_ItemCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataListItemEventArgs) Handles dlRoles.ItemCreated

            If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then

                Dim role As DotNetNuke.Security.Roles.RoleInfo = CType(e.Item.DataItem, DotNetNuke.Security.Roles.RoleInfo)

                If Not role Is Nothing Then

                    Dim rblRoles As RadioButtonList = CType(e.Item.FindControl("rblRoles"), RadioButtonList)

                    Dim eum As Enums.RoleStatus

                    If Me.RolesConfiguration.TryGetValue(role.RoleID, eum) Then

                        Select Case eum

                            Case Enums.RoleStatus.Add

                                rblRoles.SelectedIndex = 0

                            Case Enums.RoleStatus.Remove

                                rblRoles.SelectedIndex = 1

                            Case Enums.RoleStatus.Ignore

                                rblRoles.SelectedIndex = 2

                        End Select

                    Else

                        ' Neue Gruppe 
                        rblRoles.SelectedIndex = 0

                    End If

                End If

            End If

        End Sub

        Protected Sub gvProfileShow_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gvProfileShow.RowDataBound

            If e.Row.RowType = DataControlRowType.DataRow Then

                Dim item As DotNetNuke.Entities.Profile.ProfilePropertyDefinition = CType(e.Row.DataItem, DotNetNuke.Entities.Profile.ProfilePropertyDefinition)

                If Not item Is Nothing Then

                    Dim lblId As Label = CType(e.Row.FindControl("lblId"), Label)

                    Dim cbProfileShow As CheckBox = CType(e.Row.FindControl("cbProfileShow"), CheckBox)
                    Dim txtMaxLength As TextBox = CType(e.Row.FindControl("txtMaxLength"), TextBox)
                    Dim cbHtmlDecode As CheckBox = CType(e.Row.FindControl("cbHtmlDecode"), CheckBox)
                    Dim cbExtendedRoleOnly As CheckBox = CType(e.Row.FindControl("cbExtendedRoleOnly"), CheckBox)

                    If Not cbProfileShow Is Nothing Then

                        If Me.ProfilesPropertyCollectionToShowDic.TryGetValue(item.PropertyDefinitionId, Nothing) Then

                            cbProfileShow.Checked = True

                        ElseIf Me.ProfilePropertyCollectionDic.TryGetValue(item.PropertyDefinitionId, Nothing) Then

                            cbProfileShow.Checked = False

                        End If

                        cbProfileShow.Text = Me.ProfilePropertyCollectionDic(item.PropertyDefinitionId).PropertyName

                    End If

                    If Not txtMaxLength Is Nothing Then

                        txtMaxLength.Text = 0

                        If MaxLengthDic.TryGetValue(item.PropertyDefinitionId, Nothing) Then

                            txtMaxLength.Text = MaxLengthDic(item.PropertyDefinitionId)

                        End If

                    End If

                    If Not cbHtmlDecode Is Nothing Then

                        Select Case item.PropertyDefinitionId
                            'photo url
                            Case Consts.USERNAME_PROFILE_ID, Consts.EMAIL_PROFILE_ID, Consts.DISPLAYNAME_PROFILE_ID, Consts.PHOTOURL_PROFILE_ID

                                cbHtmlDecode.Visible = False

                            Case Else

                                If HtmlDecodeDic.TryGetValue(item.PropertyDefinitionId, Nothing) Then

                                    cbHtmlDecode.Checked = Convert.ToBoolean(HtmlDecodeDic(item.PropertyDefinitionId))

                                End If

                        End Select

                    End If

                    If Not cbExtendedRoleOnly Is Nothing Then

                        If ExtendedRoleOnlyDic.TryGetValue(item.PropertyDefinitionId, Nothing) Then

                            cbExtendedRoleOnly.Checked = Convert.ToBoolean(ExtendedRoleOnlyDic(item.PropertyDefinitionId))

                        End If

                    End If

                    If Not lblId Is Nothing Then

                        lblId.Text = item.PropertyDefinitionId

                    End If

                End If

            End If

        End Sub

#End Region

        'Protected Sub rptProfilesSearch_OnItemCreated(ByVal sender As Object, ByVal e As RepeaterItemEventArgs)
        'End Sub

        Protected Sub rptProfilesSearch_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles rptProfilesSearch.ItemDataBound
            Select Case e.Item.ItemType
                Case ListItemType.Header
                    CType(e.Item.FindControl("lblSearchHeader"), Label).Text = Localization.GetString("lblSearchHeader", LocalResourceFile)
                    CType(e.Item.FindControl("lblFilterHeader"), Label).Text = Localization.GetString("lblFilterHeader", LocalResourceFile)
                    CType(e.Item.FindControl("lblPropertyName"), Label).Text = Localization.GetString("lblPropertyName", LocalResourceFile)
                Case ListItemType.AlternatingItem, ListItemType.Item
                    Dim item As DotNetNuke.Entities.Profile.ProfilePropertyDefinition = CType(e.Item.DataItem, DotNetNuke.Entities.Profile.ProfilePropertyDefinition)

                    CType(e.Item.FindControl("hidProfileID"), HiddenField).Value = item.PropertyDefinitionId
                    CType(e.Item.FindControl("lblPropertyName"), Label).Text = item.PropertyName

                    Dim searchProfiles As String = CType(Settings(effority.UserDirectory.Consts.PROFILES_TO_SEARCH), String)
                    Dim filterProfiles As String = CType(Settings(effority.UserDirectory.Consts.PROFILES_TO_FILTER), String)

                    CType(e.Item.FindControl("cbxSearch"), CheckBox).Checked = InStr(searchProfiles, ";" & item.PropertyDefinitionId.ToString & ";") > 0

                    Dim cbx = CType(e.Item.FindControl("cbxFilter"), CheckBox)
                    cbx.Visible = False

                    Dim objListController As New ListController
                    Dim dataType As ListEntryInfo = objListController.GetListEntryInfo(item.DataType)
                    If (Not dataType Is Nothing) AndAlso (dataType.ListName = "DataType") AndAlso (dataType.Value = "List") Then
                        cbx.Visible = True
                        cbx.Checked = InStr(filterProfiles, ";" & item.PropertyDefinitionId.ToString & ";") > 0
                    End If

                Case Else

            End Select
        End Sub
    End Class

End Namespace